<?php 
    include_once ('global.php');
    $title =  $_POST["title"];
    $text =  $_POST["editor1"];
    
    //$mysql = new mysql("localhost","root","198639", $database, $encode);
    
    
    date_default_timezone_set('Asia/Shanghai');
    $time = date('Y-m-d H:i:s');
	 
	 $sql = "INSERT INTO articles (title,content,writetime) 
		VALUES ('$title', '$text', '$time')";

     $result = mysql_query($sql);
     
	 if(!$result) 
	 {
	 	die('Error: ' . mysql_error());
	 	echo 
			"<script>                           
			alert('失败');
			</script>";
	 }	 
	 
	 $url = "index.php"; 
	echo "<script language='javascript' type='text/javascript'>"; 
	echo "alert('成功');";
	echo "window.location.href='$url'"; 
	echo "</script>"; 

?>